import request from '@/utiles/request.js'

export const searchPost = async (searchName) => {
  return await request.get('/search/posts' ,{
    params: {searchName}
  })
}

export const searchPostByNew = async (searchName) => {
  return await request.get('/search/posts/new' ,{
    params: {searchName}
  })
}

export const searchPostByHot = async (searchName) => {
  return await request.get('/search/posts/hot' ,{
    params: {searchName}
  })
}

export const searchTagInfo  = async (tagName,userId) => {
  return await request.get('/search/tag/info' ,{
    params: {tagName,userId}
  })
}

export const searchTagByNew  = async (tagName,pageNum,pageSize) => {
  return await request.get('/search/tag/new' ,{
    params: {tagName,pageNum,pageSize}
  })
}

export const searchTagByHotWeek  = async (tagName,pageNum,pageSize) => {
  return await request.get('/search/tag/hot/week' ,{
    params: {tagName,pageNum,pageSize}
  })
}

export const searchTagByHotMonth  = async (tagName,pageNum,pageSize) => {
  return await request.get('/search/tag/hot/month' ,{
    params: {tagName,pageNum,pageSize}
  })
}

export const searchTagByHotTotal  = async (tagName,pageNum,pageSize) => {
  return await request.get('/search/tag/hot/total' ,{
    params: {tagName,pageNum,pageSize}
  })
}

export const subscribeTag = async (tagName,sign) => {
  await request.post(`/search/tag/subscribe/${sign}?tagName=${encodeURIComponent(tagName)}`)
}

export const searchUser = async (nickname) => {
  return await request.get('/search/users' ,{
    params: {nickname}
  })
}
